<!--录入第二次补缓考成绩-->
<template>
  <div class="makeup-score-entry-container">
    <div>
      <ul>
        <li>
          <span class="active">课程编号：</span>
          <span>{{ courseno }} </span>
          <span class="active">课程名称：</span>
          <span>{{ coursename }}</span>
        </li>
        <li>
          <span class="active">成绩分制：</span>
          <span>{{ cjfz }}</span>
          <span class="active">修习类型：</span>
          <span>{{ xxlx }}</span>
        </li>
      </ul>
      <ul>
        <li>
          <span class="active">学号【姓名】</span>
          <span class="active">专业班次</span>
          <span class="active">成绩性质</span>
          <span class="active">二次补缓考成绩</span>
          <span class="active">课终考核成绩</span>
          <span class="active">期中考核成绩</span>
        </li>
        <li v-for="(item, index) in tableData" :key="index">
          <span>{{ item.studentno }}【{{ item.name }}】</span>
          <span>{{ item.proclassname }}</span>
          <span>{{ item.bktype }}</span>
          <span style="padding-top: 15px;">
            <el-input
              v-model="item.onemorescore"
              style="width: 60px;padding:0"
              :disabled="item.bhkstate2 == 3 || item.bhkstate2 == 2"
            ></el-input
          ></span>
          <span style="padding-top: 15px;">
            <el-input
              v-model="item.kzkhscore"
              style="width: 60px;padding:0"
              :disabled="true"
            ></el-input
          ></span>
          <span style="padding-top: 15px;">
            <el-input
              v-model="item.qzksscore"
              style="width: 60px;padding:0"
              :disabled="true"
            ></el-input
          ></span>
        </li>
      </ul>
    </div>
    <!-- <el-button type="success" @click="zc">暂存</el-button> -->
    <!-- <div style="border:none;margin: 50px 50%;">
      <el-button type="success" @click="querySave">保存</el-button>
    </div> -->
    <div style="display:flex;width:100px;margin:0 auto;border:none">
      <div class="button-group" @click="querySave" style="margin-left:20px">
        <div>保存</div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  queryListr,
  queryPostListr,
  queryr,
  queryzc2,
} from "@/api/courseAchievement/manualEntry";
export default {
  name: "makeupScoreEntry",
  data() {
    return {
      coursenumber: "121",
      coursename: "12",
      scoretypecode: "32",
      studytype: "21",
      input: "",
      input1: "",
      tableData: [],
    };
  },
  methods: {
    queryList: function () {
      return new Promise(() => {
        queryListr(this.$route.query.planid).then((res) => {
          this.courseno = res.data.data[0].courseno;
          this.coursename = res.data.data[0].coursename;
          this.cjfz = res.data.data[0].cjfz;
          this.xxlx = res.data.data[0].xxlx;
          console.log(res.data);
        });
      });
    },
    queryPostList: function () {
      return new Promise(() => {
        queryPostListr(this.$route.query.planid).then((res) => {
          this.courseno = res.data.data[0].courseno;
          this.coursename = res.data.data[0].coursename;
          this.cjfz = res.data.data[0].cjfz;
          this.xxlx = res.data.data[0].xxlx;
          this.tableData = res.data.data;
          console.log(res.data.data);
        });
      });
    },
    zc() {
      return new Promise(() => {
        queryzc2(this.tableData).then((res) => {
          this.$message({
            type: "success",
            message: "保存成功!",
          });
          this.$router.push({
            path: "/admin/scoreManagement/delayTestes",
          });
        });
      });
    },
    querySave: function () {
      // let arr = [
      //   {
      //     id: this.tableData[0].id,
      //     onemorescore: this.tableData[0].onemorescore,
      //     studentno: this.tableData[0].studentno,
      //     bhkstate2: this.tableData[0].bhkstate2,

      //   },
      // ];
      let arr = [];
      for (let i = 0; i < this.tableData.length; i++) {
        arr.push(this.tableData[i].bhkstate2)
      }
      if(arr.includes('1')){
        this.$confirm('提交之后无法进行修改，确认要提交吗？')
          .then(_ => { 
            return new Promise(() => {
              queryr(this.tableData).then((res) => {
                this.$message({
                  type: "success",
                  message: "保存成功!",
                });
                this.$router.push({
                  path: "/admin/scoreManagement/delayTestes",
                });
              });
            });
          })
      } else {
        this.$router.push({
          path: "/admin/scoreManagement/delayTestes",
        });
      }
    },
  },
  mounted() {
    // this.queryList();
    this.queryPostList();
  },
};
</script>

<style scoped lang="less">
.makeup-score-entry-container {
  > div {
    width: 100%;
    height: auto;
    border: 1px solid rgba(0, 76, 167, 0.8);
    border-radius: 6px;
    margin: 0;
    ul {
      list-style: none;
      li {
        border-bottom: 1px solid rgba(0, 76, 167, 0.4);
        height: auto;
        > span {
          display: inline-block;
          font-size: 14px;
          color: rgba(0, 76, 167, 1);
          padding-left: 54px;
          border-right: 1px solid rgba(0, 76, 167, 0.4);
          height: 70px;
          vertical-align: middle;
          padding-top: 24px;
          &:nth-child(n) {
            width: 20%;
          }
          &:nth-child(2n) {
            width: 30%;
          }
          &:last-child {
          }
          &.active {
            font-size: 16px;
            color: rgba(0, 76, 167, 1);
            font-weight: bold;
            background: rgba(77, 129, 192, 0.1);
            text-align: center;
            padding-left: 0;
          }
        }
      }
      &:nth-child(1) {
        li {
          > span {
            height: 70px;
          }
        }
      }
      &:nth-child(2) {
        margin-top: 33px;
        li {
          height: auto;
          border-bottom: 1px solid rgba(0, 76, 167, 0.4);
          > span {
            width: 16.666%;
            text-align: center;
            padding-left: 0;
            height: 70px;
            &.active {
              border-top: 1px solid rgba(0, 76, 167, 0.4);
            }
          }
        }
      }
    }
    .button-group {
      text-align: center;
      margin-top: 76px;
      cursor: pointer;

      > div {
        display: inline-block;
        /* width: 74px;
        height: 27px; */
        background: rgba(241, 255, 248, 1);
        border: 1px solid #02c86c;
        border-radius: 4px;
        font-size: 18px;
        font-weight: 400;
        color: #02c86c;
        text-align: center;
        padding: 6px 20px;
      }
    }
  }
}
/deep/.el-input__inner{
  text-align: center;
  padding: 0;
}
</style>